#ifndef _MSEQ_H
#define _MSEQ_H

/*
 * $Log: mseq.h,v $
 * Revision 1.2  2000/05/15 11:10:51  bjc97r
 * sys/types.h has been included so that unsigned long can be recognised.
 *
 * Revision 1.1  2000/05/03 14:30:04  bjc97r
 * Initial revision
 *
 */

typedef struct {
  unsigned long state; /* PN register state */
  unsigned long mask;  /* the mask to get the next state */
} Mseq;

/* 
 * It create an m-sequence generator with the given generator
 * polynomial and the initial register sate.
 * The pointer to the m-sequence generator is returned.
 * The max degree of the generator poly is 31.
 */
Mseq * mseq_create( unsigned deg, unsigned long poly, unsigned long seed );

/* mseq_free() deallocates the memory space for the m-sequence generator. */
void mseq_free( Mseq * mseq );

/*
 * mseq() gives the next m-sequence bit of the m-sequence generator.
 * The generated bit is unipolar, ie 1 or 0.
 */
char mseq( Mseq * mseq );

#endif /* _MSEQ_H */

